'use strict';

const Controller = require('egg').Controller;

class MenuController extends Controller {
    //根据不同角色获取不同的菜单  （权限）
    async menuList() {
        let {ctx,service} = this;
        let {role_id} = ctx.info;
        console.log("role_id",role_id)
        //1.容错
        if(role_id){
            let menuList = await service.menu.menuList(role_id);
            ctx.body = {
                code:1,
                data:menuList
            }
        }else{
            ctx.body = {
                code:2,
                msg:'参数有误'
            }
        }
    }
}

module.exports = MenuController;
